package net.cathackers.devel.scmp.chat.impl.xmpp.iqhandlers;

import net.cathackers.devel.scmp.chat.impl.xmpp.iqcomponent.IQHandlerClassifierImpl;
import net.cathackers.devel.scmp.chat.impl.xmpp.iqcomponent.interfaces.IQHandler;
import net.cathackers.devel.scmp.chat.impl.xmpp.iqcomponent.interfaces.IQHandlerClassifier;
import net.cathackers.devel.scmp.chat.interfaces.ChatManager;
import net.cathackers.devel.scmp.factories.SCMPFactory;
import net.cathackers.devel.scmp.xmpp.IQPacket;
import net.cathackers.devel.scmp.xmpp.IQType;

public class PingHandler extends IQHandler {
    private IQHandlerClassifier classifier_;
    private ChatManager manager_;

    public PingHandler() {
	classifier_ = new IQHandlerClassifierImpl("ping", "urn:xmpp:ping");
	manager_ = SCMPFactory.getChatManager();
    }
    @Override
    public IQHandlerClassifier getClassifier() {
	return classifier_;
    }

    @Override
    public void process(IQPacket t) {
	IQPacket reply = new IQPacket(IQType.result);
	reply.setID(t.getID());
	reply.setTo(t.getFrom());
	reply.setBaseStreamID(t.getBaseStreamID());
	manager_.deliverToUser(reply);
    }

}
